<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 1、遍历数组
    var arr = [1, 2, 3, 4]
    console.log(...arr);
    // 2、当做数组中的元素
    var arr_1 = [0, ...arr]
    console.log(arr_1);
    // 3、数组深拷贝
    var arr_2 = [...arr_1]
    arr_1.unshift(1)
    console.log(arr_1);
    console.log(arr_2);
    // 4、函数的调用
    function fn(a, b, c) {
        console.log(a, b, c);
    }
    // fn(arr_1[0],arr_1[1])
    fn(...arr_1)
    // 5、与解构赋值连用
    var [x, y, z] = [...arr_1]
    console.log(x, y, z);
    // 6、将伪数组转换成真正的数组
    var str = '我们是web31'
    console.log(Array.from(str));
    console.log([...str]);
</script>
<script>
    var obj = {
        name: "zs",
        age: 18
    }
    // 1、遍历对象
    console.log({ ...obj });
    // 2、对象深拷贝
    var obj_1 = { ...obj }
    delete obj.age
    console.log(obj);
    console.log(obj_1);
    // 3、合并
    var a = {
        a: 1,
        b: 3
    }
    var b = {
        b: 2,
        ...a,
        // a: 1,
        // b: 3
    }
    console.log(b);
</script>

</html>